import cv2
from matplotlib.pyplot import gray
import numpy as np

blockSize = 2
ksize = 3
k = 0.04

img = cv2.imread("E:\\chess.png")

# 灰度化
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Harris角点检测
dst = cv2.cornerHarris(gray, blockSize, ksize, k)

# 角点展示，取dst中的最大值进行判断，大于阈值的全被显示出来
img[dst > 0.01*dst.max()] = [0,0,255]   # 红色显示

cv2.imshow('harris',img)
cv2.waitKey(0)